package org.sny7.openOfflineList.listener;

import java.awt.Component;

import javax.swing.JLabel;
import javax.swing.JList;

import org.jvnet.substance.api.renderers.SubstanceDefaultListCellRenderer;
import org.sny7.openOfflineList.bean.Game;
import org.sny7.openOfflineList.util.CountryIconKeeper;

public class GameListItemRenderer extends SubstanceDefaultListCellRenderer {

	private static final long serialVersionUID = 1L;

	public Component getListCellRendererComponent(JList list, Object value,
			int index, boolean isSelected, boolean cellHasFocus) {
		JLabel result = (JLabel) super.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus);
		Game game = (Game) value;
		result.setIcon(CountryIconKeeper.getIcon(game.getLocation()));
		result.setText(game.getText());
		return result;
	}

}
